<div class="row-fluid"  id="user_register">
	<div class="span10 offset1">
		<div class="span12">
        	<?php echo $this->translate('会员注册'); ?>
        </div>
        <div class="well">
			<form class="form-horizontal" method="post" enctype="multipart/form-data" name="user_register_form" id="user_register_form">
        	<?php if ($this->frontwebsite()->getUserIni('user_register_state') == 'true') { ?>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('会员名称'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              		<input type="text" id="user_name" placeholder="<?php echo $this->translate('输入会员名称'); ?>" name="user_name">
            		</div>
          		</div>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('会员密码'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              		<input type="password" id="user_password" name="user_password" placeholder="<?php echo $this->translate('输入会员密码'); ?>">
            		</div>
          		</div>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('确认密码'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              		<input type="password" id="user_com_passwd" name="user_com_passwd" placeholder="<?php echo $this->translate('输入确认密码'); ?>">
            		</div>
          		</div>
				<?php
				$userEmailRegisterState = $this->frontwebsite()->getRegOrLoginIni('register_email_state');
				$userPhoneRegisterState = $this->frontwebsite()->getRegOrLoginIni('register_phone_state');

				$userPhoneCaptchaState = $this->frontwebsite()->websiteCaptchaState('phone_user_register_captcha');
				?>
				<?php if ($userEmailRegisterState == 'true') { ?>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('电子邮箱'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              		<input type="text" id="user_email" name="user_email" placeholder="<?php echo $this->translate('输入电子邮件'); ?>">
            		</div>
          		</div>
				<?php } ?>
				<?php if ($userPhoneRegisterState == 'true') { ?>
					<div class="control-group">
						<label for="input01" class="control-label"><?php echo $this->translate('手机号码'); ?><span class="must_add_value">*</span>：</label>
						<div class="controls">
							<input type="text" id="user_phone" name="user_phone" placeholder="<?php echo $this->translate('输入手机号码'); ?>">
						</div>
					</div>
					<?php if($userPhoneCaptchaState == 'true') { ?>
					<div class="control-group">
						<label for="input01" class="control-label"><?php echo $this->translate('手机验证码'); ?><span class="must_add_value">*</span>：</label>
						<div class="controls">
							<input type="text" class="input-small" id="phone_captcha" name="phone_captcha" placeholder="<?php echo $this->translate('输入手机验证码'); ?>">
							<input type="button" class="btn btn-primary btn-small" id="get_phone_captcha" value="<?php echo $this->translate('获取验证码'); ?>">
							<input type="hidden" name="<?php echo $this->captcha_csrf['name']; ?>" id="<?php echo $this->captcha_csrf['name']; ?>" value="<?php echo $this->captcha_csrf['value']; ?>">
						</div>
					</div>
					<?php } ?>
				<?php } ?>
				<?php if($this->user_reg_extend['inputArray']) {
					foreach($this->user_reg_extend['inputArray'] as $exValue) {
						?>
						<div class="control-group">
							<label for="input01" class="control-label"><?php echo $exValue['field_title']; ?><?php if($exValue['field_null'] == 2) { ?><span class="must_add_value">*</span><?php } ?>：</label>
							<div class="controls">
								<?php echo $exValue['input']; ?>
							</div>
						</div>
					<?php } } ?>
                <?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('验证码'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              		<input type="text" class="input-small" id="captcha_code" name="captcha_code" placeholder="<?php echo $this->translate('输入验证码'); ?>">&nbsp;<span id="captcha_id"></span>
            		</div>
          		</div>
                <?php } ?>
            	<div class="control-group">
            	<label for="input01" class="control-label"><?php echo $this->translate('注册协议'); ?><span class="must_add_value">*</span>：</label>
            		<div class="controls">
              			<label class="checkbox"><?php echo $this->translate('同意'); ?><input type="checkbox" name="agreement" id="agreement" value="1" />&nbsp;&nbsp;<a href="javascript:;" onclick="show_agreement();"><?php echo $this->translate('点击查看注册协议'); ?></a></label>
                        
            		</div>
          		</div>
            	<div class="control-group">
            		<div class="controls">
                <input type="hidden" name="<?php echo $this->register_csrf['name']; ?>" value="<?php echo $this->register_csrf['value']; ?>" />
                <input type="hidden" name="http_referer" value="<?php echo $this->http_referer; ?>" />
            	<button class="btn btn-primary" type="submit"><?php echo $this->translate('提交注册用户'); ?></button>
            		</div>
          		</div>
				<?php if($this->frontwebsite()->getUserOtherLoginState() == 'true') { ?>
					<div class="control-group">
						<label for="input01" class="control-label"><?php echo $this->translate('其他账号登录'); ?>：</label>
						<div class="controls">
							<?php
							$otherLoginArray = $this->frontwebsite()->getUserOtherLoginIni();
							if(!empty($otherLoginArray)) {
								foreach($otherLoginArray as $othKey => $othValue) {
									if($othValue['login_state'] == 'true') {
										$othKey = strtolower($othKey);
										?>
										<a href="<?php echo $this->url('frontuser/default',array('action'=>'otherlogin'), array('query'=>array('login_type'=>$othKey))); ?>" style="margin-right: 8px;"><img src="<?php echo $this->basePath('public/img/login/'.$othKey.'_login.png'); ?>"></a>
										<?php
									}
								}
							}
							?>
						</div>
					</div>
				<?php } ?>
            <?php } else {  
                echo '<div><h4>'. $this->frontwebsite()->getUserIni('register_close_message') . '</h4></div>';
                } ?>
            </form>
        </div>
    </div>   
</div>

<div class="modal hide fade" id="agreementModal" style="width:700px;">
  <div class="modal-header">
    <h3><?php echo $this->translate('注册协议'); ?></h3>
  </div>
  <div class="modal-body">
    <p><?php echo nl2br($this->frontwebsite()->getUserIni('user_register_body')); ?></p>
  </div>
  <div class="modal-footer">
  	<a class="btn" data-dismiss="modal"><?php echo $this->translate('关闭'); ?></a>
  </div>
</div>
<script>
//客户保存验证
$(document).ready(function() {
	$("#user_register_form").validate({
		success : function(label){
			label.addClass('validate_right').text('OK!');
		},
		rules: {
			user_name: {
				required: true,
				maxlength:30,
				remote :{
					url : '<?php echo $this->url('frontuser/default/user_id',array('action'=>'check','controller'=>'user','check_type'=>'user_name','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>',
					type : 'post',
					date : {
						user_name :function(){
							return $('#user_name').val();
						}
					}
				}
			},
			<?php if ($userEmailRegisterState == 'true') { ?>
			user_email: {
				required: true,
				email: true,
				remote :{
					url : '<?php echo $this->url('frontuser/default/user_id',array('action'=>'check','controller'=>'user','module'=>'user','check_type'=>'user_email','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>',
					type : 'post',
					date : {
						user_email :function(){
							return $('#user_email').val();
						}
					}
				}
			},
			<?php } ?>
			<?php if ($userPhoneRegisterState == 'true') { ?>
			user_phone: {
				required: true,
				isMobile: true,
				remote :{
					url : '<?php echo $this->url('frontuser/default/user_id',array('action'=>'check','controller'=>'user','module'=>'user','check_type'=>'user_phone','user_id'=>($this->user_info ? $this->user_info->user_id : '0'))); ?>',
					type : 'post',
					date : {
						user_phone :function(){
							return $('#user_phone').val();
						}
					}
				}
			},
			<?php } ?>
				<?php if ($userPhoneRegisterState == 'true' and $userPhoneCaptchaState == 'true') { ?>
			phone_captcha: {
					required:true,
					remote :{
						url : '<?php echo $this->url('shopfront/default/captcha-check',array('action'=>'phoneCaptcha','captcha_check'=>1)); ?>',
						type : 'post',
						date : {
							phone_captcha :function(){
								return $("#phone_captcha").val();
							}
						}
					}
				},
				<?php } ?>
            user_password: {
				required: true,
				minlength: 6,
				maxlength: 20
			},
			user_com_passwd: {
				required: true,
				minlength: 6,
				maxlength: 20,
				equalTo: '#user_password'
			},
			agreement : {
				required: true
			}
			<?php if (isset($this->user_reg_extend['jsCheck']['jsStart']) and !empty($this->user_reg_extend['jsCheck']['jsStart'])) { echo ','.implode(',', $this->user_reg_extend['jsCheck']['jsStart']); } ?>
            <?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
            ,
			captcha_code: {
				required:true,
				remote :{
					url : '<?php echo $this->url('shopfront/default/captcha-check',array('action'=>'captcha','captcha_check'=>1)); ?>',
					type : 'post',
					date : {
						captcha_code :function(){
							return $("#captcha_code").val();
						}
					}
				}
			}
            <?php } ?>
		},
		messages: {
			user_name: {
				required: "<?php echo $this->translate('请输入会员登录名称！'); ?>",
				maxlength:"<?php echo $this->translate('会员登录名称最长为30个汉字！'); ?>",
				remote: "<?php echo $this->translate('该会员名已经存在！'); ?>"
			},
			<?php if ($userEmailRegisterState == 'true') { ?>
			user_email: {
				required: "<?php echo $this->translate('请输入电子邮箱！'); ?>",
				email: "<?php echo $this->translate('电子邮箱格式错误！'); ?>",
				remote: "<?php echo $this->translate('该邮箱已经存在'); ?>"
			},
			<?php } ?>
			<?php if ($userPhoneRegisterState == 'true') { ?>
			user_phone: {
				required: "<?php echo $this->translate('手机号码不能为空！'); ?>",
				isMobile: "<?php echo $this->translate('请输入正确的手机号码！'); ?>",
				remote: "<?php echo $this->translate('该手机号码已经存在！'); ?>"
			},
			<?php } ?>
			<?php if ($userPhoneRegisterState == 'true' and $userPhoneCaptchaState == 'true') { ?>
			phone_captcha: {
				required:"<?php echo $this->translate('手机验证码不能为空！'); ?>",
				remote : "<?php echo $this->translate('手机验证码错误！'); ?>"
			},
			<?php } ?>
            user_password: {
				required: "<?php echo $this->translate('请输入密码！'); ?>",
				minlength: "<?php echo $this->translate('至少输入6位密码！'); ?>",
				maxlength: "<?php echo $this->translate('密码最长为20位！'); ?>"
			},
			user_com_passwd: {
				required: "<?php echo $this->translate('请输入确认密码！'); ?>",
				minlength: "<?php echo $this->translate('至少输入6位确认密码！'); ?>",
				maxlength: "<?php echo $this->translate('确认密码最长为20位！'); ?>",
				equalTo: "<?php echo $this->translate('两次输入的密码不一致！'); ?>"
			},
			agreement : {
				required: "<?php echo $this->translate('必须勾选同意注册协议才能注册！'); ?>"
			}
			<?php if (isset($this->user_reg_extend['jsCheck']['jsEnd']) and !empty($this->user_reg_extend['jsCheck']['jsEnd'])) { echo ','.implode(',', $this->user_reg_extend['jsCheck']['jsEnd']); } ?>
            <?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
            ,
			captcha_code: {
				required:"<?php echo $this->translate('验证码不能为空！'); ?>",
				remote : "<?php echo $this->translate('验证码错误！'); ?>"
			}
            <?php } ?>
		},
		submitHandler:function(form){
			check_user_form(form);
		}
	});
});
function check_user_form(form) {
	<?php
	if(isset($this->user_reg_extend['jsCheck']['jsCheckboxAndRadio']) and !empty($this->user_reg_extend['jsCheck']['jsCheckboxAndRadio'])) {
		echo implode('', $this->user_reg_extend['jsCheck']['jsCheckboxAndRadio']);
	} ?>

	form.submit();
}
//查看注册协议
function show_agreement() {
	$('#agreementModal').modal('show');	
}
<?php if ($this->frontwebsite()->websiteCaptchaState('user_register_captcha') == 'true') { ?>
//验证码添加
function captchaAdd() {
	$.get("<?php echo $this->url('shopfront/default',array('action'=>'captcha')); ?>",{},
	function(data){
		$("#captcha_id").html('<img src="<?php echo $this->basePath('/'); ?>'+data.captcha_file+'" border="0" >&nbsp;&nbsp;<a href="javascript:;" onclick="captchaAdd()"><?php echo $this->translate('更换验证码'); ?></a>');
},'json');
}
captchaAdd();
<?php } ?>

<?php if ($userPhoneRegisterState == 'true' and $userPhoneCaptchaState == 'true') { ?>
var waittime=<?php echo $this->frontwebsite()->websiteCaptchaState('phone_captcha_time'); ?>;
function captchatime() {
	if (waittime == 0) {
		$('#user_phone').removeAttr("readonly");

		$('#get_phone_captcha').removeAttr("disabled");
		$('#get_phone_captcha').val('<?php echo $this->translate('获取验证码'); ?>');
		waittime = <?php echo $this->frontwebsite()->websiteCaptchaState('phone_captcha_time'); ?>;
	}
	else {
		$('#get_phone_captcha').val("<?php echo $this->translate('重新获取'); ?>(" + waittime + ")");
		waittime--;
		setTimeout(function() {
					captchatime()
				},
				1000)
	}
}
document.getElementById("get_phone_captcha").onclick=function(){
	$.ajax({
		type : 'POST',
		url	 : '<?php echo $this->url('shopfront/default',array('action'=>'phoneCaptcha')); ?>',
		data : "user_phone="+$('#user_phone').val()+"&checkrepeat=true&captcha_security="+$('#captcha_security').val(),
		success: function(msg){
			if(msg != '') {
				alert(msg);
				return false;
			} else {
				$('#user_phone').attr("readonly", true);
				$('#get_phone_captcha').attr("disabled", true);
				captchatime();
			}
		}
	});
}
<?php } ?>
</script>